<?php 
$show_validator = true;
include TMPL_PATH.'/public/header.phtml';
?>
<script type="text/javascript">
<!--
$(function(){
	$.formValidator.initConfig({autotip:true,formid:"myform",onerror:function(msg){}});
	<?php if(!isset($tpl)){?>
	$("#path_alias").formValidator({onshow:"请输入模板标识,模板标识唯一性，方便程序中使用",onfocus:"模板标识只由字母组成"}).inputValidator({min:4,max:20,onerror:"模板标识应该为4-20位之间"}).regexValidator({regexp:"letter",datatype:"enum",onerror:"模板标识只由字母组成"}).ajaxValidator({
		type : "get",
		url : "<?php echo U('user/check_email_template_ajax');?>",
		data :"",
		datatype : "html",
		async:'false',
		success : function(data){	
            if( data == "1" )
			{
                return true;
			}
            else
			{
                return false;
			}
		},
		buttons: $("#dosubmit"),
		onerror : "模板标识已存在。",
		onwait : "请稍候..."
		});
<?php }?>
	<?php 
			if(isset($languageList) && $languageList):
				foreach ($languageList as $language_id => $language_name):
		?>
				var language_name = "<? echo $language_name; ?>";
				var language_id = <?php echo $language_id;?>;
	$("#title_"+language_id).formValidator({onshow:"请输入邮件邮件"+language_name+"标题",onfocus:"请输入邮件"+language_name+"标题",oncorrect:"输入正确"}).inputValidator({min:1,onerror:"请输入邮件"+language_name+"标题"});
	$("#content_"+language_id).formValidator({onshow:"请输入邮件"+language_name+"内容",onfocus:"请输入邮件"+language_name+"内容",oncorrect:"输入正确"}).inputValidator({min:1,onerror:"请输入邮件"+language_name+"内容"});
	<?php 
			endforeach;
		endif;
	?>
})
//-->
</script>
<script type="text/javascript" src="/statics/xheditor/xheditor-zh-cn.min.js"></script>
<div class="subnav">
    <div class="content-menu ib-a blue line-x">
        <a href='<?php echo U('user/tpl_list');?>'><em>模板列表</em></a><span>|</span>
        <a href='javascript:;' class="on"><em><?php if(isset($tpl) && $tpl)echo'编辑';else echo'添加';?>模板</em></a>
    </div>
</div>
<div class="pad_10">
<div class="col-tab">
<ul class="tabBut cu-li">
<?php 
$langCount = 0;
if(isset($languageList) && $languageList){
		$langCount = count($languageList);
}
$langCount++;
?>
<?php 
	if(isset($languageList) && $languageList):
		$i = 0;
		foreach ($languageList as $language_id => $language_name):
			$i++;
	?>
<li id="tab_setting_<?php echo $i;?>" <?php if($i==1)echo 'class="on"';?> onclick="SwapTab('setting','on','',<?php echo $langCount;?>,<?php echo $i;?>);"><?php echo $language_name;?></li>
<?php 
		endforeach;
	endif;
	?>
<li id="tab_setting_<?php echo $langCount;?>" onclick="SwapTab('setting','on','',<?php echo $langCount;?>,<?php echo $langCount;?>);">基本选项</li>
</ul>

<form name="myform" action="__SELF__" method="post" id="myform">

<?php 
	if(isset($languageList) && $languageList):
		$i = 0;
		foreach ($languageList as $language_id => $language_name):
			$i++;
?>
<div id="div_setting_<?php echo $i;?>" class="contentList pad-10 <?php if($i>1)echo 'hidden';?>">
	<table width="100%" class="table_form contentWrap">
		<tr>
			<td>邮件标题</td> 
			<td><input type="text" name="tpl[<?php echo $language_id;?>][title]" id="title_<?php echo $language_id;?>" class="input-text" size="100" value="<?php echo isset($tpl['items'][$language_id]['title']) ? $tpl['items'][$language_id]['title'] : null;?>"/></td>
		</tr>
		<tr>
			<td>邮件内容</td> 
			<td><textarea name="tpl[<?php echo $language_id;?>][content]" id="content_<?php echo $language_id;?>"  class="xheditor" style="height:300px;width:80%;"><?php echo isset($tpl['items'][$language_id]['content']) ? $tpl['items'][$language_id]['content'] : null;?></textarea></td>
		</tr>
	</table>
</div>
	<?php 
		endforeach;
	endif;
	?>
<div id="div_setting_<?php echo $langCount;?>" class="contentList pad-10 hidden">
	<table width="100%" class="table_form contentWrap">
		<tr>
			<td width="80">模板标识</td> 
			<td><input type="text" name="path_alias" value="<?php echo isset($tpl['path_alias']) ? $tpl['path_alias'] : null;?>" class="input-text" id="path_alias" <?php if(isset($tpl) && $tpl)echo'readonly="true"';?>/></td>
		</tr>
		<tr>
			<td width="80">模板名称</td> 
			<td><input type="text" name="name" class="input-text" id="name" value="<?php echo isset($tpl['name']) ? $tpl['name'] : null;?>"/><div class="infoShow">后台显示名称</div></td>
		</tr>
		<tr>
			<td>标签变量</td> 
			<td><textarea name="variable" style="height:50px;width:500px;" class="inputtext"><?php echo isset($tpl['variable']) ? $tpl['variable'] : null;?></textarea></td>
		</tr>
	</table>
</div>
    <div class="bk15"></div>
    <input name="dosubmit" type="submit" value="提交" class="button" id="dosubmit" />
</form>

</div>
</body>
</html>